package com.ihr360.alps.api;

import com.ihr360.commons.data.util.Pair;
import feign.Headers;
import feign.Param;
import feign.RequestLine;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * TODO: 如何根据条件获取数据呢？例如获取指定月份的数据？？？？
 * 此接口应该只针对内部
 * https://github.com/OpenFeign/feign
 **/
@RestController
public interface ServiceProvider {
    static String FIELD_CONNECTOR = "_";

    static final class SERVICE_ID {

        /**
         * 员工信息
         */
        public final static String STAFF_ROSTER = "STAFF_ROSTER";

        /**
         * 社保公积金
         */
        public final static String SIHF = "SIHF";


        /**
         * 考勤月报
         */
        public final static String ATTENDANCE_MONTHLY_REPORT = "ATT_M_R";

        /**
         * 考勤日报
         */
        public final static String ATTENDANCE_DAIRY_REPORT = "ATT_M_D";

        /**
         * 考勤时间段报告
         */
        public final static String ATTENDANCE_PERIOD_REPORT = "ATT_P_R";

        /**
         * 税表
         */
        public static final String SYS_TAX_TABLE = "$TAX_TABLE";

        /**
         * 工作日历
         */
        public static final String SYS_WORK_CALENDAR = "$WORK_CALENDAR";

        /**
         * 工资加班规则
         */
        public static final String SALARY_OT_RULE = "$SAL_OT_RULE";

        /**
         * 病假扣款规则
         */
        public static final String SALARY_SL_RULE = "$SAL_SL_RULE";

        /**
         * 事假扣款规则
         */
        public static final String SALARY_PL_RULE = "$SAL_PL_RULE";

        /**
         * 入离职调整规则
         */
        public static final String SALARY_ENTRY_DISMISS_ADJUST_RULE = "$SAL_ED_ADJUST_RULE";

        /**
         * 薪资调整规则（转正和调岗调薪）
         */
        public static final String SALARY_ADJUST_RULE = "$SAL_ADJUST_RULE";

        /**
         * 员工薪资档案
         */
        public final static String STAFF_SALARY = "STAFF_SAL";
    }


    final class CriteriaField {
        public final static String START_DATE = "startDate";
        public final static String END_DATE = "endDate";
    }

    final class STAFF_ROSTER  {
        public final static String ENROLL_IN_DATE = "enrollInDate";
        public final static String LEAVE_DATE = "leaveDate";
    }

    /**
     * 获取公司下某个服务所有记录
     *
     * @return
     */
    @RequestLine("GET /?companyId={companyId}")
    Map<String, Map<String, Object>> getItems(@Param(value = "companyId") String companyId
    );

    /**
     * 获取公司下某个服务某条记录
     *
     * @param id
     * @param companyId
     * @return
     */
    @RequestLine("GET /{id}?companyId={companyId}")
    Pair<String, Map<String, Object>> getItem(
            @Param(value = "companyId") String companyId,
            @Param(value = "id") String id);

    /**
     * 根据公司id和员工id列表获取一组数据
     *
     * @return
     */
    @Headers("Content-Type: application/json")
    @RequestLine("POST /?companyId={companyId}")
    Map<String, Map<String, Object>> getItems(@Param(value = "companyId") String companyId,
                                              IDListRequest<String> idListRequest);

    /**
     * 根据公司id和员工id列表和年月信息获取一组数据
     *
     * @return
     */
    @Headers("Content-Type: application/json")
    @RequestLine(value = "POST /{year}/{month}?companyId={companyId}")
    Map<String, Map<String, Object>> getItems(@Param(value = "companyId") String companyId,
                                              @Param(value = "year") int year,
                                              @Param(value = "month") int month,
                                              IDListWithCriteriaRequest<String> request);


    /**
     * 根据公司id和员工id列表和其他查询条件获取一组数据(最复杂的应用场景)
     *
     * @return
     */
    @Headers("Content-Type: application/json")
    @RequestLine(value = "POST /{service}/search?companyId={companyId}")
    Map<String, Map<String, Object>> getItemsByCriteria(@Param(value="companyId") String companyId,
                                                        IDListWithCriteriaRequest<String> request);

}